package org.heart.springsecurity.controller;


import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletRequest;
import org.heart.springsecurity.pojo.Login;
import org.heart.springsecurity.service.AuthenticationService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("auth")
@CrossOrigin("*")
public class AuthenticationController {
    @Resource
    private AuthenticationService authenticationService;


    @PostMapping("login")
    String login(Login login) {
        return authenticationService.login(login);
    }

    @PostMapping("logout")
    public String logout( HttpServletRequest request) {
        return authenticationService.logout(request);
    }

    @PostMapping("refreshToken")
    public String refreshToken(HttpServletRequest request) {
        return authenticationService.refreshToken(request);
    }


}
